using UnityEngine;
using UnityEngine.UI;

public class Intro : MonoBehaviour
{
    User32Controller_1 _windowController;

    void Start()
    {
        ShowUI();
        _windowController = new User32Controller_1();
    }


    // 绑定UI按钮事件
    public void OnMaximizeClick() => _windowController.Maximize();
    public void OnMinimizeClick() => _windowController.Minimize();
    public void OnRestoreClick() => _windowController.Restore();
    public void OnWriteClick()
    {
        _windowController.IsBlack = false;
        _windowController.ConfigureDwmAttributes();
    }
    public void OnBlackClick()
    {
        _windowController.IsBlack = true;
        _windowController.ConfigureDwmAttributes();
    }
    // 绑定拖拽区域事件
    public void OnDragBegin() => _windowController.BeginDrag();
    public void OnDragging() => _windowController.Drag();
    public void OnDragEnd() => _windowController.EndDrag();


    public Button 最大化, 最小化, 还原, 退出, 亮色, 暗色;
    void ShowUI()
    {
        最大化.onClick.AddListener(OnMaximizeClick);
        最小化.onClick.AddListener(OnMinimizeClick);
        还原.onClick.AddListener(OnRestoreClick);
        退出.onClick.AddListener(CloseWindow);

        亮色.onClick.AddListener(OnWriteClick);
        暗色.onClick.AddListener(OnBlackClick);
    }


    void CloseWindow()
    {
#if UNITY_EDITOR
        // 编辑器下停止播放
        UnityEditor.EditorApplication.isPlaying = false;
#else
    // 真机或打包环境下退出
    Application.Quit();
#endif
    }

    void OnDestroy()
    {
        _windowController?.Dispose();

    }
}